﻿using System;
using System.Text.RegularExpressions;
using System.Windows.Data;

namespace Kiva7.ValueConverter
{
    public class TagStripperConverter : IValueConverter
    {
        public object Convert(object value,
                              Type targetType,
                              object parameter,
                              System.Globalization.CultureInfo culture)
        {
            if (value is string)
            {
                return StripTags(value as string);
            }
            return value;
        }

        private static string StripTags(string value)
        {
            Regex regex = new Regex(@"</?.*>");

            return regex.Replace(value, "");
        }

        public object ConvertBack(object value,
                                  Type targetType,
                                  object parameter,
                                  System.Globalization.CultureInfo culture)
        {
            return value;
        }
    }
}